# -*- coding: utf-8 -*-

"""
上传大文件

方法：

"""

import urllib2
import mmap
from settings import URL, BIG_FILE_PATH

with open(BIG_FILE_PATH, 'rb') as f
    # Open the file as a memory mapped string. Looks like a string, but 
    # actually accesses the file behind the scenes. 
    mmapped_file_as_string = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
    req = urllib2.Request(URL, f.read())
    req.add_header("Content-Type", "application/zip")
    resp = urllib2.urlopen(request)
    mmapped_file_as_string.close()
